package com.grj.community.all.controller;


import com.grj.community.all.common.Result;
import com.grj.community.all.entity.User;
import com.grj.community.all.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author 14505
 */
@RestController
@RequestMapping("user")
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;

    @GetMapping
    public String list(){
        return userService.list().toString();
    }

    @PostMapping
    public Result<Object> add(@RequestBody User user){
        return userService.save(user)?Result.success("添加成功"):Result.fail("添加失败");
    }
}
